﻿using Microsoft.Extensions.Options;
using seejee_Backendium.Data.Repositores;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace seejee_Backendium.Data.Services
{
    public class UserService
    {
        private readonly UserRepository _userRepository;

        public UserService(UserRepository userRepository)
        {
            _userRepository = userRepository;
        }

        public bool ValidateUser(string username, string password)
        {
            DataTable userTable = _userRepository.GetUserByUsername(username);
            if (userTable.Rows.Count == 0)
            {
                return false;
            }

            string storedPassword = userTable.Rows[0]["password"].ToString();
            //return storedPassword == password;
            return string.Equals(storedPassword, password, StringComparison.Ordinal);
        }


    }
}
